import re

f = open("test.txt","r")
content = f.read();
list = []

while content != "":
    # Recognize Emails
    pattern = re.compile("\w+@\w+.\w+")
    m =  pattern.match(content)
    if m!=None:
        print "Email: ",m.group(0);
        list.append(m.group(0))
        content = content[m.end():]
        continue
    #Recognize Dates
    pattern = re.compile("[0-9]+[/-][0-9]+([/-][0-9]+)?")
    m = pattern.match(content)
    if m!=None:
        print "Date: ",m.group(0)
        list.append(m.group(0))
        content = content[m.end():]
        continue
    #Recognize URL
    pattern = re.compile("http://(\w+\.)+\w+")
    m = pattern.match(content);
    if m!=None:
        print "URL: ",m.group(0)
        list.append(m.group(0))
        content = content[m.end():]
        continue
    #recognize Money
    pattern = re.compile("[$][0-9,\.]+[mkb]?")
    m = pattern.match(content)
    if m!=None:
        print "Money: ",m.group(0)
        list.append(m.group(0))
        content = content[m.end():]
        continue
    #recognize Mr, Mrs
    pattern = re.compile("(Mr.)|(Mrs.)|(Dr.)|(PhD.)")
    m = pattern.match(content)
    if m!=None:
        print "Token: ",m.group(0)
        list.append(m.group(0))
        content = content[m.end():]
        continue
    #Recognize Words
    pattern = re.compile("[a-zA-Z]+('s)*")
    m = pattern.match(content)
    if m!=None:
        print "Word: ",m.group(0)
        list.append(m.group(0))
        content = content[m.end():]
        continue
    #Recognize Numbers    
    pattern = re.compile("[0-9]+([,\.0-9]+)*")
    m = pattern.match(content);
    if m!= None:
        print "Number: ",m.group(0)
        list.append(m.group(0))
        content = content[m.end():]
        continue
    #Recognize Punctuation
    pattern = re.compile("[!\?;\.\,\"\'\)\(\{\}:]")
    m = pattern.match(content);
    if m!= None:
        print "Token: ",m.group(0)
        list.append(m.group(0))
        content = content[m.end():]
        continue
    #Skip
    content = content[1:]
print list